/**
 * 
 */
package com.innovationhero.mainUI.client.UX;

import java.util.Iterator;
import java.util.List;
import java.util.SortedMap;

import com.google.gwt.event.dom.client.MouseOutEvent;
import com.google.gwt.event.dom.client.MouseOutHandler;
import com.google.gwt.event.dom.client.MouseOverEvent;
import com.google.gwt.event.dom.client.MouseOverHandler;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;

/**
 * Will provide an IPhone PointNavigationMenu eXperiance for the user 
 * @author InnovationHero
 *
 */
public class Navigation 
 extends Composite
implements IdeaUXEventHandler
{
	
	private static final Widget NavigationWidget = new Navigation();
	
	private TextBox navpoint1 = new TextBox();
	private TextBox navpoint2 = new TextBox();
	private TextBox navpoint3 = new TextBox();
	private TextBox navpoint4 = new TextBox();
	
	
	
	public Navigation(){
	
	}

	/* 
	 * The cool constructor 
	 * 
	 * */
	@SuppressWarnings("unchecked")
	public Navigation(HandlerManager eventBus ){

		// The non Widget Constructor that deals with the RootPanel directly   
		RootPanel rootPanel = RootPanel.get();
		rootPanel.add(navpoint1,0, 100);
		rootPanel.add(navpoint2,0, 200);
		rootPanel.add(navpoint3,0, 300);
		rootPanel.add(navpoint4,0, 400);
		eventBus.addHandler(IdeaUXEvent.TYPE, this);
	}
	
	
	public Navigation(SortedMap navPoints, HandlerManager eventBus) {
		// TODO Auto-generated constructor stub
		
		NavigationWidget(navPoints, eventBus);
	}

	public Widget NavigationWidget(SortedMap navPoints, HandlerManager eventBus ){

		// This Navigation should be a Widget class,  
		
		
		

		// Get the number of points in the navigation menu and create the navigation point image and set each one its values using a for loop
//		for(int i=0; i<navPoints.size(); i++){
//			Image	navpoint = new Image(navPoints.values().)
//       }
//		
		Iterator iterator = navPoints.keySet().iterator();
		  while (iterator.hasNext()) {
		  Object key = iterator.next();
		//  System.out.println("key : " + key + " value :" + navPoints.get(key));
		  Image navPoint = new Image(navPoints.get(key).toString());

			RootPanel rootPanel = RootPanel.get();

	rootPanel.add(navPoint);
eventBus.addHandler(IdeaUXEvent.TYPE, this);  
		  }
		
		return NavigationWidget;
	}
	
//	NEffectPanel example1EP = new NEffectPanel();  
//	Fade theFade = new Fade();  
//	Image img = new Image("ski.png");  
//	example1EP.add(img);  
//	example1EP.addEffect(theFade);  
//	RootPanel.get().add(example1EP);
//	
//	

	@Override
	public void mouseOver(IdeaUXEvent event) {
		// TODO Auto-generated method stub

		
		MouseOverHandler navpoint1handler = new MouseOverHandler() {
			
			@Override
			public void onMouseOver(MouseOverEvent event) {
				// TODO Auto-generated method stub
		navpoint1.setText("I am hit");		
			}
		};;;
		// Make the Navigation widget shine 
		navpoint1.addMouseOverHandler(navpoint1handler);
		MouseOverHandler navpoint2handler = new MouseOverHandler() {
			
			@Override
			public void onMouseOver(MouseOverEvent event) {
				// TODO Auto-generated method stub
				navpoint2.setText("I am hit");
			}
		};;;
		navpoint2.addMouseOverHandler(navpoint2handler);
		MouseOverHandler navpoint3handler = new MouseOverHandler() {
			
			@Override
			public void onMouseOver(MouseOverEvent event) {
				// TODO Auto-generated method stub
				navpoint3.setText("I am hit");
			}
		};;;
		navpoint3.addMouseOverHandler(navpoint3handler);
		MouseOverHandler navpoint4handler = new MouseOverHandler() {
			
			@Override
			public void onMouseOver(MouseOverEvent event) {
				// TODO Auto-generated method stub
				navpoint4.setText("I am hit");
			}
		};;;
		navpoint4.addMouseOverHandler(navpoint4handler);
		// Make the the background of the webapp change, or change the whole theme of the app into somthing diff
		
		
		// Logic of If-Else Statment to make a diff effect for each mouseOver on each navigation Point,
		// 1st point Make the current easeOut to the left and Options easeIn from the right
		// 2nd point Make the current easeOut to the 
	}

	@Override
	public void mouseOut(IdeaUXEvent event) {
		// TODO Auto-generated method stub
		// TODO Auto-generated method stub

		
		MouseOutHandler navpoint1handler = new MouseOutHandler() {
			
			@Override
			public void onMouseOut(MouseOutEvent event) {
				// TODO Auto-generated method stub
		navpoint1.setText("I am out");		
			}
		};;;
 
		navpoint1.addMouseOutHandler(navpoint1handler);
		
		// Number 2 
		MouseOutHandler navpoint2handler = new MouseOutHandler() {
			
			@Override
			public void onMouseOut(MouseOutEvent event) {
				// TODO Auto-generated method stub
				navpoint2.setText("I am out");
			}
		};;;
		navpoint2.addMouseOutHandler(navpoint2handler);
		
		// Number 3
		MouseOutHandler navpoint3handler = new MouseOutHandler() {
			
			@Override
			public void onMouseOut(MouseOutEvent event) {
				// TODO Auto-generated method stub
				navpoint3.setText("I am out");
			}
		};;;
		navpoint3.addMouseOutHandler(navpoint3handler);
		
		// Number 4
		MouseOutHandler navpoint4handler = new MouseOutHandler() {
			
			@Override
			public void onMouseOut(MouseOutEvent event) {
				// TODO Auto-generated method stub
				navpoint4.setText("I am out");
			}
		};;;
		navpoint4.addMouseOutHandler(navpoint4handler);
		
	}
}
